package experiment4;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-11-06 13:01
 */
public class Test1 {
    public static void main(String[] args) {
        int[] a = {1, 2, 3};
        perm(a, 0, 2);
    }

    public static void perm(int v[], int left, int right) {
        if (left == right)
            System.out.println(Arrays.toString(v));
        else
            for (int i = left; i <= right; i++) {
                swap(v, left, i);
                perm(v, left + 1, right);
                swap(v, left, i);
            }
    }

    private static void swap(int[] v, int left, int i) {
        int temp = v[left];
        v[left] = v[i];
        v[i] = temp;
    }
}
